import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
from selenium.webdriver.support.select import Select
testCase="DBshop013_后台商品管理-商品分类编辑流程"

firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu3(firefox,'商品管理','管理分类','商品分类')
firefox.find_element_by_link_text('添加分类').click()
firefox.find_element_by_id('class_name').send_keys(goodsClassName)
firefox.find_element_by_id('class_sort').clear()
firefox.find_element_by_id('class_sort').send_keys('1')
firefox.find_element_by_xpath('//button[@type="submit"]').click()
firefox.find_element_by_xpath('//td[contains(.,"%s")]/following-sibling::td[4]/a[2]'%goodsClassName).click()
firefox.find_element_by_id('class_sort').clear()
firefox.find_element_by_id('class_sort').send_keys('4')
firefox.find_element_by_xpath('//button[text()=" 保存分类"]').click()
time.sleep(2)


a=firefox.find_element_by_xpath\
    ('//td[contains(.,"%s")]/following-sibling::td[2]/input'%goodsClassName).get_attribute("value")
if a=="4":
    writeLog("%s 测试通过" % testCase)
else:
    writeLog("%s 测试不通过" % testCase)
    getPhoto(firefox)

firefox.quit()
